home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / jock.zip / TOTSRC11.ZIP / TOTWIN.PAS < prev    next >
Pascal/Delphi Source File  |  1993-06-08  |  37KB  |  1,303 lines

  1. {               Copyright 1991 TechnoJock Software, Inc.               }
  2. {                          All Rights Reserved                         }
  3. {                         Restricted by License                        }
  4.  
  5. {                             Build # 1.10d                            }
  6.  
  7. Unit totWIN;
  8. {$I TOTFLAGS.INC}
  9.  
  10. {
  11.  Development History:
  12.              Mar 15 91  1.00a   Changed DesqView checks.
  13.              Mar 29 91  1.00b   Added method SetWinRestrict to control
  14.                                 whether screen coords are set to within
  15.                                 window border.
  16.              Apr  4 91  1.00c   Fixed window coordinate problem when a
  17.                                 window is stretched.
  18.              Apr 23 91  1.00d   Enabled SetAllowMove for all window
  19.                                 types.
  20.              Feb 03 92  1.00e   Captured 600 as Key Lastkey
  21.              Feb 24 93  1.10a   Change Winkey to check vRemove
  22.              Mar 05 93  1.10b   Changed memory check in Window Move
  23.              May 03 93  1.10c   Set cursor to 1,1 when Window drawn
  24.                                 to avoid a range check error.
  25.                                 Wait for Mouse Release when closing
  26.              Jun 08 93  1.10d   Added checks of vRemove before removing
  27.                                 windows (Thanks Bill).
  28. }
  29.  
  30. {
  31.  Development Notes:
  32.                 600 = Close Window
  33.                 601 = Moved
  34.                 602 = Resized
  35.                 610 = Scroll Up One
  36.                 611 = Scroll Down One
  37.                 612 = Scroll Left one
  38.                 613 = Scroll Right one
  39.                 614 = Vertical Scroll Bar
  40.                 615 = Horizontal Scroll Bar
  41. }
  42.  
  43. INTERFACE
  44.  
  45. uses DOS, CRT, totSYS, totLOOK, totINPUT, totFAST, totMISC;
  46.  
  47. TYPE
  48.  
  49. WinPtr = ^WinOBJ;
  50. pWinOBJ = ^WinOBJ;
  51. WinOBJ = object
  52.    vBorder: tCoords;
  53.    vOuter: tCoords;
  54.    vClose: boolean;            {is close icon active}
  55.    vUnderneathPtr: pointer;    {ptr to saved screen}
  56.    vSavedSize: longint;        {amount of memory saved}
  57.    vTitle: string;             {window title}
  58.    vBorderAttr: byte;          {border attribute}
  59.    vTitleAttr: byte;           {title attribute}
  60.    vBodyAttr: byte;            {main text attribute}
  61.    vIconsAttr: byte;           {close and zoom icon attribute}
  62.    vStyle: byte;               {border style}
  63.    vRemove: boolean;           {remove the window when done}
  64.    vCursX: byte;               {saved cursor location}
  65.    vCursY: byte;               {saved       -"-      }
  66.    vCursTop: byte;             {saved cursor size}
  67.    vCursBot: byte;             {saved     -"-    }
  68.    vOldWin: tByteCoords;       {previous window coords}
  69.    vOldWinConfine: boolean;    {were window coords active}
  70.    vMVisible: boolean;         {was mouse visible}
  71.    vFillWin: boolean;          {clear window core when redrawn}
  72.    vWinRestrict: boolean;      {are windows coords relative to border}
  73.    {methods...}
  74.    constructor Init;
  75.    procedure   SetSize(X1,Y1,X2,Y2,Style:byte);
  76.    procedure   SetTitle(Title:string);
  77.    procedure   SetColors(Border,Body,Title,Icons: byte);
  78.    procedure   SetRemove(On:boolean);
  79.    procedure   SetClose(On:boolean);
  80.    procedure   SetWinRestrict(On:boolean);
  81.    procedure   SetWindow;
  82.    procedure   GetSize(var X1,Y1,X2,Y2,Style:byte);
  83.    function    GetX:byte;
  84.    function    GetY:byte;
  85.    function    GetStyle: byte;
  86.    function    GetBorderAttr: byte;
  87.    function    GetTitleAttr: byte;
  88.    function    GetBodyAttr: byte;
  89.    function    GetIconsAttr: byte;
  90.    function    GetRemoveStatus: boolean;
  91.    procedure   Save;
  92.    procedure   PartSave(X1,Y1,X2,Y2:byte; var Dest);
  93.    procedure   PartRestore(X1,Y1,X2,Y2:byte; var Source);
  94.    procedure   ComputeSavedCoords;
  95.    procedure   DrawCore;
  96.    procedure   GrowDraw;
  97.    procedure   Remove;
  98.    procedure   WinGetKey(var K:word;var X,Y:byte);
  99.    procedure   SetBoundary(X1,Y1,X2,Y2:byte);                  VIRTUAL;
  100.    procedure   WinKey(var K:word;var X,Y:byte);                VIRTUAL;
  101.    procedure   Draw;                                           VIRTUAL;
  102.    destructor  Done;                                           VIRTUAL;
  103. end; {WinOBJ}
  104.  
  105. MoveWinPtr = ^MoveWinOBJ;
  106. pMoveWinOBJ = ^MoveWinOBJ;
  107. MoveWinOBJ = object (WinOBJ)
  108.    vBoundary: tCoords;       {max area in which window can move}
  109.    vMoveKey: word;
  110.    vAllowMove: boolean;
  111.    {methods...}
  112.    constructor Init;
  113.    procedure   SetMoveKey(K:word);
  114.    procedure   SetAllowMove(On:boolean);
  115.    procedure   BuildBackground(var BackScr: ScreenOBJ);
  116.    procedure   RemoveShadow(var OriginalScreen: ScreenOBJ);
  117.    procedure   RefreshUnderneath(BackScr: ScreenOBJ);
  118.    procedure   WMove(UsingMouse:boolean;OldX,OldY:byte);
  119.    procedure   WinKey(var K:word;var X,Y:byte);                VIRTUAL;
  120.    procedure   SetBoundary(X1,Y1,X2,Y2:byte);                  VIRTUAL;
  121.    destructor  Done;                                           VIRTUAL;
  122. end; {MoveWinOBJ}
  123.  
  124. pScrollWinOBJ = ^ScrollWinOBJ;
  125. ScrollWinOBJ = object (MoveWinOBJ)
  126.    vScrollV: boolean;       {show vertical scroll bar}
  127.    vScrollH: boolean;       {show horizontal scroll bar}
  128.    {methods ...}
  129.    constructor Init;
  130.    procedure   SetScrollable(Vert,Horiz:boolean);
  131.    procedure   DrawHorizBar(Current,Max: longint);
  132.    procedure   DrawVertBar(Current,Max: longint);
  133.    procedure   Winkey(var K:word;var X,Y:byte);                VIRTUAL;
  134.    procedure   Draw;                                           VIRTUAL;
  135.    destructor  Done;                                           VIRTUAL;
  136. end; {ScrollWinOBJ}
  137.  
  138. StretchWinPtr = ^StretchWinOBJ;
  139. pStretchWinOBJ = ^StretchWinOBJ;
  140. StretchWinOBJ = object (ScrollWinOBJ)
  141.    vZoomed: boolean;        {is window zoomed at present}
  142.    vPreZoom: tCoords;        {size of window in Unzoomed state}
  143.    vMinWidth: byte;         {min width of SmartWin}
  144.    vMinDepth: byte;         {min depth of SmartWin}
  145.    vStretchKey:word;        {keycode for manual stretch}
  146.    vZoomKey:word;           {keycode for zoom}
  147.    vAllowStretch: boolean;  {is user allowed to stretch}
  148.    vSmartStretch: boolean;  {refresh window during stretch}
  149.    {methods ...}
  150.    constructor Init;
  151.    procedure   SetMinSize(Width,depth:byte);
  152.    procedure   Stretch(UsingMouse:boolean;OldX,OldY:byte);
  153.    procedure   SetAllowStretch(On:boolean);
  154.    procedure   ToggleZoom;
  155.    procedure   Refresh;
  156.    procedure   StretchRefresh;                                 VIRTUAL;
  157.    procedure   Winkey(var K:word;var X,Y:byte);                VIRTUAL;
  158.    procedure   Draw;                                           VIRTUAL;
  159.    destructor  Done;                                           VIRTUAL;
  160. end; {StretchWinOBJ}
  161.  
  162. procedure WinInit;
  163.  
  164. IMPLEMENTATION
  165.  
  166. {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  167. {                                                               }
  168. {     U N I T   P R O C E D U R E S   &   F U N C T I O N S     }
  169. {                                                               }
  170. {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  171.  
  172. procedure Error(Err:byte);
  173. {routine to display error}
  174. const
  175.    Header = 'WinTOT error: ';
  176. var
  177.    Msg : string;
  178. begin
  179.    Case Err of
  180.    1: Msg := 'Not enough memory to create window';
  181.    2: Msg := 'Invalid window dimensions';
  182.    3: Msg := 'Not enough memory to create SmartWin';
  183.    else  Msg := 'Unknown Error';
  184.    end; {case}
  185.    Writeln(Header,Msg);
  186. {Maybe Add non-fatal compiler directive}
  187.    halt;
  188. end; {Error}
  189.  
  190. {||||||||||||||||||||||||||||||||||||}
  191. {                                    }
  192. {    W i n O B J   M E T H O D S     }
  193. {                                    }
  194. {||||||||||||||||||||||||||||||||||||}
  195.  
  196. constructor WinOBJ.Init;
  197. {}
  198. begin
  199.    SetSize(10,5,70,20,1);
  200.    SetTitle('');
  201.    SetRemove(true);
  202.    with LookTOT^ do
  203.        SetColors(WinBorder,WinBody,WinTitle,WinIcons);
  204.    vUnderneathPtr := Nil;
  205.    vMVisible := true;
  206.    vClose := true;
  207.    vFillWin := true;
  208.    vWinRestrict := true;
  209. end; {of const WinOBJ.Init}
  210.  
  211. procedure WinOBJ.SetSize(X1,Y1,X2,Y2,Style:byte);
  212. {}
  213. begin
  214. {$IFDEF CHECK}
  215.    if (X2 < X1 + 2)
  216.    or (Y2 < Y1 + 2)
  217.    or (Y2 > Screen.Depth)
  218.    or (X2 > Screen.Width) then
  219.       Error(2);
  220. {$ENDIF}
  221.    vBorder.X1 := X1;
  222.    vBorder.Y1 := Y1;
  223.    vBorder.X2 := X2;
  224.    vBorder.Y2 := Y2;
  225.    vStyle := Style;
  226. end; {WinOBJ.SetSize}
  227.  
  228. procedure WinOBJ.GetSize(var X1,Y1,X2,Y2,Style:byte);
  229. {}
  230. begin
  231.    X1 := vBorder.X1;
  232.    Y1 := vBorder.Y1;
  233.    X2 := vBorder.X2;
  234.    Y2 := vBorder.Y2;
  235.    Style := vStyle;
  236. end; {WinOBJ.GetSize}
  237.  
  238. function WinOBJ.GetX:byte;
  239. {}
  240. begin
  241.    GetX := vBorder.X1;
  242. end; {WinOBJ.GetX}
  243.  
  244. function WinOBJ.GetY:byte;
  245. {}
  246. begin
  247.    GetY := vBorder.Y1;
  248. end; {WinOBJ.GetY}
  249.  
  250. function WinOBJ.GetStyle:byte;
  251. {}
  252. begin
  253.    GetStyle := vStyle;
  254. end; {WinOBJ.GetStyle}
  255.  
  256. function WinOBJ.GetBorderAttr: byte;
  257. {}
  258. begin
  259.    GetBorderAttr := vBorderAttr;
  260. end; {WinOBJ.GetBorderAttr}
  261.  
  262. function WinOBJ.GetTitleAttr: byte;
  263. {}
  264. begin
  265.    GetTitleAttr := vTitleAttr;
  266. end; {WinOBJ.GetTitleAttr}
  267.  
  268. function WinOBJ.GetBodyAttr: byte;
  269. {}
  270. begin
  271.    GetBodyAttr := vBodyAttr;
  272. end; {WinOBJ.GetBodyAttr}
  273.  
  274. function WinOBJ.GetIconsAttr: byte;
  275. {}
  276. begin
  277.    GetIconsAttr := vIconsAttr;
  278. end; {WinOBJ.GetIconsAttr}
  279.  
  280. procedure WinOBJ.SetRemove(On:boolean);
  281. {}
  282. begin
  283.    vRemove := On;
  284. end; {Window.SetRemove}
  285.  
  286. procedure WinOBJ.SetClose(On:boolean);
  287. {}
  288. begin
  289.    vClose := On;
  290. end; {WinOBJ.SetClose}
  291.  
  292. procedure WinOBJ.SetWinRestrict(On:boolean);
  293. {}
  294. begin
  295.    vWinRestrict := On;
  296. end; {WinOBJ.SetWinRestrict}
  297.  
  298. function WinOBJ.GetRemoveStatus: boolean;
  299. {}
  300. begin
  301.    GetRemoveStatus := vRemove;
  302. end; {WinOBJ.GetRemoveStatus}
  303.  
  304. procedure WinOBJ.SetTitle(Title:string);
  305. {}
  306. begin
  307.    vTitle := Title;
  308. end; {WinOBJ.SetTitle}
  309.  
  310. procedure WinOBJ.SetColors(Border,Body,Title,Icons: byte);
  311. {}
  312. begin
  313.    if Border <> 0 then
  314.       vBorderAttr := Border;
  315.    if Title <> 0 then
  316.       vTitleAttr := Title;
  317.    if Body <> 0 then
  318.       vBodyAttr := Body;
  319.    if Icons <> 0 then
  320.       vIconsAttr := Icons;
  321. end; {WinOBJ.SetColors}
  322.  
  323. procedure WinOBJ.SetBoundary(X1,Y1,X2,Y2:byte);
  324. {abstract}
  325. begin end;
  326.  
  327. procedure WinOBJ.ComputeSavedCoords;
  328. {checks shodow position and style and computes saved screen coords}
  329. begin
  330.    ShadowTOT^.OuterCoords(vBorder,vOuter);
  331. end; {WinOBJ.ComputeSavedCoords}
  332.  
  333. procedure WinOBJ.SetWindow;
  334. {}
  335. begin
  336.    if vWinRestrict then {1.00b}
  337.       with vBorder do
  338.       case vStyle of
  339.          0: Screen.SetWindow(X1,Y1,X2,Y2);
  340.          6: Screen.SetWindow(succ(X1),Y1+3,pred(X2),Y2);
  341.          else Screen.SetWindow(succ(X1),succ(y1),pred(X2),pred(Y2));
  342.       end; {case}
  343. end; {WinOBJ.SetWindow}
  344.  
  345. procedure WinOBJ.Save;
  346. {}
  347. var
  348.   MemoryNeeded: longint;
  349. begin
  350.    ComputeSavedCoords;
  351.    MemoryNeeded := succ(vOuter.X2-vOuter.X1)*succ(vOuter.Y2-vOuter.Y1)*2;
  352.    if MaxAvail < MemoryNeeded then
  353.       Error(1)
  354.    else
  355.    begin
  356.       if vUnderneathPtr <> nil then
  357.       begin
  358.          freemem(vUnderneathPtr,vSavedSize);
  359.          vUnderneathPtr := nil;
  360.       end;
  361.       getmem(vUnderneathPtr,MemoryNeeded);
  362.       PartSave(vOuter.X1,vOuter.Y1,vOuter.X2,vOuter.Y2,vUnderneathPtr^);
  363.       vSavedSize := MemoryNeeded;
  364.       vCursX := Screen.WhereX;
  365.       vCursY := Screen.WhereY;
  366.       Screen.CursSave;
  367.       vCursTop:= Screen.CursTop;
  368.       vCursBot:= Screen.CursBot;
  369.       Screen.WindowCoords(vOldWin);
  370.       vOldWinConfine := Screen.WindowActive;
  371.    end;
  372. end; {WinOBJ.Save}
  373.  
  374. procedure WinOBJ.DrawCore;
  375. {}
  376. begin
  377.    if (vStyle in [1..5]) and vClose then
  378.    begin
  379.       with vBorder do
  380.       begin
  381.          Screen.BoxEngine(X1,Y1,X2,Y2,4,4,vBorderAttr,vTitleAttr,vBodyAttr,
  382.                           vStyle,vFillWin,vTitle);
  383.          Screen.WriteAT(X1+2,Y1,vBorderAttr,'[ ]');
  384.          Screen.WriteAT(X1+3,Y1,vIconsAttr,'■');
  385.       end;
  386.    end
  387.    else
  388.       with vBorder do
  389.          Screen.BoxEngine(X1,Y1,X2,Y2,0,0,vBorderAttr,vTitleAttr,vBodyAttr,
  390.                           vStyle,vFillWin,vTitle);
  391.    if (vStyle = 6) and vClose then
  392.       with vBorder do
  393.          Screen.WriteAT(X1+3,Y1,vIconsAttr,'■');
  394. end; {WinOBJ.DrawCore}
  395.  
  396. procedure WinOBJ.Draw;
  397. {}
  398. var WasOn: boolean;
  399. begin
  400.    vMVisible := Mouse.Visible;
  401.    Save;
  402.    WasOn := Screen.WindowOff;
  403.    ShadowTOT^.DrawShadow(vBorder);
  404.    DrawCore;
  405.    SetWindow;
  406.    GotoXY(1,1);        {1.10c}
  407.    if not vMVisible then
  408.       Mouse.Show;
  409. end; {WinOBJ.Draw}
  410.  
  411. procedure WinOBJ.GrowDraw;
  412. {}
  413. var
  414.   I,TX1,TY1,TX2,TY2,Ratio : integer;
  415.   WasOn: boolean;
  416. begin
  417.    Save;
  418.    vMVisible := Mouse.Visible;
  419.    WasOn := Screen.WindowOff;
  420.    with vBorder do
  421.    begin
  422.       if 2*(Y2 -Y1 +1) > X2 - X1 + 1 then
  423.          Ratio :=   2
  424.       else
  425.          Ratio :=  1;
  426.       TX2 := (X2 - X1) div 2 + X1 + 2;
  427.       TX1 := TX2 - 3;                 {needs a box 3 by 3 minimum}
  428.       TY2 := (Y2 - Y1) div 2 + Y1 + 2;
  429.       TY1 := TY2 - 3;
  430.       if (X2-X1) < 3 then
  431.       begin
  432.          TX2 := X2;
  433.          TX1 := X1;
  434.       end;
  435.       if (Y2-Y1) < 3 then
  436.       begin
  437.          TY2 := Y2;
  438.          TY1 := Y1;
  439.       end;
  440.       repeat
  441.          Screen.PartClear(TX1,TY1,TX2,TY2,vBodyAttr,' ');
  442.          if TX1 >= X1 + (1*Ratio) then 
  443.             TX1 := TX1 - (1*Ratio) 
  444.          else 
  445.             TX1 := X1;
  446.          if TY1 > Y1  then 
  447.             TY1 := TY1 - 1;
  448.          if TX2 + (1*Ratio) <= X2 then 
  449.             TX2 := TX2 + (1*Ratio) 
  450.          else 
  451.             TX2 := X2;
  452.          if TY2 + 1 <= Y2 then 
  453.             TY2 := TY2 + 1;
  454.          delay(10);
  455.       Until (TX1 = X1) and (TY1 = Y1) and (TX2 = X2) and (TY2 = Y2);
  456.       DrawCore;
  457.    end;
  458.    ShadowTOT^.DrawShadow(vBorder);
  459.    SetWindow;
  460.    if not vMVisible then
  461.       Mouse.Show;
  462. end; {WinOBJ.GrowDraw}
  463.  
  464. procedure WinOBJ.PartSave(X1,Y1,X2,Y2:byte; var Dest);
  465. {}
  466. var
  467.    I,w : byte;
  468.    Wid : word;
  469.    ScreenAdr: integer;
  470.    Pntr: pointer;
  471.    Mvisible: boolean;
  472. begin
  473.    w := succ(X2- X1);
  474.    Pntr := Screen.ScreenPtr;
  475.    Mvisible := Mouse.Visible;
  476.    Wid := Monitor^.Width*2;
  477.    if MVisible then
  478.       Mouse.Hide;
  479.    for I :=  Y1 to Y2 do
  480.    begin
  481.       ScreenAdr := Pred(I)*Wid + Pred(X1)*2;
  482.       Screen.MoveFromScreen(Mem[seg(Pntr^):ofs(Pntr^)+ScreenAdr],
  483.                         Mem[seg(Dest):ofs(dest)+(I-Y1)*w*2],
  484.                         w);
  485.    end;
  486.    if MVisible then
  487.       Mouse.Show;
  488. end; {WinOBJ.PartSave}
  489.  
  490. procedure WinOBJ.PartRestore(X1,Y1,X2,Y2:byte; var Source);
  491. {}
  492. var
  493.    I,w : byte;
  494.    Wid: word;
  495.    ScreenAdr: integer;
  496.    Pntr: pointer;
  497.    Mvisible: boolean;
  498. begin
  499.    w := succ(X2- X1);
  500.    Pntr := Screen.ScreenPtr;
  501.    Wid := Monitor^.Width*2;
  502.    MVisible := Mouse.Visible;
  503.    if MVisible then
  504.       Mouse.Hide;
  505.    for I :=  Y1 to Y2 do
  506.    begin
  507.       ScreenAdr := Pred(I)*Wid + Pred(X1)*2;
  508.       Screen.MoveToScreen(Mem[seg(Source):ofs(Source)+(I-Y1)*w*2],
  509.                       Mem[seg(Pntr^):ofs(Pntr^)+ScreenAdr],
  510.                       w);
  511.    end;
  512.    if MVisible then
  513.       Mouse.Show;
  514. end; {WinOBJ.PartRestore}
  515.  
  516. procedure WinOBJ.Remove;
  517. {}
  518. begin
  519.    if vUnderneathPtr <> Nil then
  520.    begin
  521.       Mouse.Hide;
  522.       PartRestore(vOuter.X1,vOuter.Y1,vOuter.X2,vOuter.Y2,vUnderneathPtr^);
  523.       freemem(vUnderneathPtr,vSavedSize);
  524.       vUnderneathPtr := nil;
  525.       if vOldWinConfine then
  526.          with vOldWin do
  527.             Screen.SetWindow(X1,Y1,X2,Y2)
  528.       else
  529.          Screen.ResetWindow;
  530.       Screen.GotoXY(vCursX,vCursY);
  531.       Screen.CursSize(vCursTop,vCursBot);
  532.       if vMVisible then
  533.          Mouse.Show;
  534.    end;
  535. end; {WinOBJ.Remove}
  536.  
  537. procedure WinOBJ.WinGetKey(var K:word;var X,Y:byte);
  538. {}
  539. begin
  540.    with key do
  541.    begin
  542.       Key.GetInput;
  543.       K := Key.LastKey;
  544.       X := Key.LastX;
  545.       Y := Key.LastY;
  546.       WinKey(K,X,Y);
  547.    end;
  548. end; {WinOBJ.WinGetKey}
  549.  
  550. procedure WinOBJ.WinKey(var K:word;var X,Y:byte);      
  551. {}
  552. begin 
  553.    if  (K = 513) and (Y = vBorder.Y1) 
  554.    and (X = vBorder.X1 + 3) and vClose then
  555.    begin
  556.       if vRemove then  {1.10a}
  557.          Remove;
  558.       K := 600;  {Closed}
  559.       Key.vLastKey := K;  {1.00e}
  560.    end;
  561. end; {WinOBJ.WinKey}
  562.  
  563. destructor WinOBJ.Done;
  564. {}
  565. begin
  566.     if (vRemove) and (vUnderneathPtr <> Nil)  then
  567.        Remove;
  568.     if vUnderneathPtr <> Nil then
  569.        freemem(vUnderneathPtr,vSavedSize);
  570. end; {WinOBJ.Done}
  571. {||||||||||||||||||||||||||||||||||||||||||||}
  572. {                                            }
  573. {    M o v e W i n O B J   M E T H O D S     }
  574. {                                            }
  575. {||||||||||||||||||||||||||||||||||||||||||||}
  576. constructor MoveWinOBJ.Init;
  577. {}
  578. begin
  579.    WinOBJ.Init;
  580.    vAllowMove := true;
  581.    vMoveKey := LookTOT^.WinMoveKey;
  582.    SetBoundary(1,1,Monitor^.Width,Monitor^.Depth);
  583. end; {MoveWinOBJ.Init}
  584.  
  585. procedure MoveWinOBJ.SetMoveKey(K:word);
  586. {}
  587. begin
  588.    vMoveKey := K; {1.00d}
  589. end; {MoveWinOBJ.SetMoveKey}
  590.  
  591. procedure MoveWinOBJ.SetBoundary(X1,Y1,X2,Y2:byte);
  592. {}
  593. begin
  594.    vBoundary.X1 := X1;
  595.    vBoundary.Y1 := Y1;
  596.    vBoundary.X2 := X2;
  597.    vBoundary.Y2 := Y2;
  598. end; {MoveWinOBJ.SetBoundary}
  599.  
  600. procedure MoveWinOBJ.BuildBackground(var BackScr: ScreenOBJ);
  601. {saves the screen and replaces the contents of the screen
  602.  where the window lies with the image saved behind the window.
  603. }
  604. var
  605.    I,w : byte;
  606.    Wid : word;
  607.    ImageAdr: integer;
  608.    Pntr: pointer;
  609. begin
  610.    BackScr.Save;    {save current screen}
  611.    w := succ(vOuter.X2- vOuter.X1);
  612.    Pntr := BackScr.ScreenPtr;
  613.    Wid := Monitor^.Width*2;
  614.    for I :=  vOuter.Y1 to vOuter.Y2 do
  615.    begin
  616.       ImageAdr := Pred(I)*Wid + Pred(vOuter.X1)*2;
  617.       Move(Mem[seg(vUnderneathPtr^):ofs(vUnderneathPtr^)+(I-vOuter.Y1)*w*2],
  618.            Mem[seg(Pntr^):ofs(Pntr^)+ImageAdr],
  619.            w*2);
  620.    end;
  621. end; {MoveWinOBJ.BuildBackground}
  622.  
  623. procedure MoveWinOBJ.RefreshUnderneath(BackScr: ScreenOBJ);
  624. {Takes image from saved screen and moves it to the window's saved
  625.  image at UnderneathPtr.
  626. }
  627. var
  628.    I,w : byte;
  629.    Wid : word;
  630.    ImageAdr: integer;
  631.    Pntr: pointer;
  632. begin
  633.    {dispose of window memory, and get required memory}
  634.    freemem(vUnderneathPtr,vSavedSize);
  635.    w := succ(vOuter.X2- vOuter.X1);
  636.    vSavedSize := succ(vOuter.Y2 - vOuter.Y1)*W*2;
  637.    getmem(vUnderneathPtr,vSavedSize);
  638.    Pntr := BackScr.ScreenPtr;
  639.    Wid := Monitor^.Width*2;
  640.    for I :=  vOuter.Y1 to vOuter.Y2 do
  641.    begin
  642.       ImageAdr := Pred(I)*Wid + Pred(vOuter.X1)*2;
  643.       Move(Mem[seg(Pntr^):ofs(Pntr^)+ImageAdr],
  644.            Mem[seg(vUnderneathPtr^):ofs(vUnderneathPtr^)+(I-vOuter.Y1)*w*2],
  645.            w*2);
  646.    end;
  647. end; {MoveWinOBJ.RefreshUnderneath}
  648.  
  649. procedure MoveWinOBJ.RemoveShadow(var OriginalScreen: ScreenOBJ);
  650. {}
  651. begin
  652.    if vOuter.X1 < vBorder.X1 then   {shadowleft}
  653.       OriginalScreen.PartDisplay(vOuter.X1,vOuter.Y1,pred(vBorder.X1),vOuter.Y2,vOuter.X1,vOuter.Y1);
  654.    if vOuter.X2 > vBorder.X2 then   {shadowright}
  655.       OriginalScreen.PartDisplay(succ(vBorder.X2),vOuter.Y1,vOuter.X2,vOuter.Y2,succ(vBorder.X2),vOuter.Y1);
  656.    if vOuter.Y1 < vBorder.Y1 then   {shadowUp}
  657.       OriginalScreen.PartDisplay(vOuter.X1,vOuter.Y1,vOuter.X2,pred(vBorder.Y1),vOuter.X1,vOuter.Y1);
  658.    if vOuter.Y2 > vBorder.Y2 then  {shadowDown}
  659.       OriginalScreen.PartDisplay(vOuter.X1,succ(vBorder.Y2),vOuter.X2,vOuter.Y2,vOuter.X1,succ(vBorder.Y2));
  660. end; {MoveWinOBJ.RemoveShadow}
  661.  
  662. procedure MoveWinOBJ.WMove(UsingMouse:boolean;OldX,OldY:byte);
  663. var
  664.    Mvisible,
  665.    WasOn,
  666.    Left,Center,Right : boolean;
  667.    X,Y : Byte;
  668.    DeltaX, DeltaY : shortint;
  669.    ScrPtr,
  670.    OldPtr,
  671.    SmartWinImagePtr : pointer;
  672.    Wid: word;
  673.    CTop,CBot,CX,CY:byte;
  674.    W,D: byte;
  675.    OldLocation : tCoords;
  676.    OriginalScreen: ScreenOBJ;
  677.  
  678.   procedure CaptureSmartWin;
  679.   {saves image of window}
  680.   var I : integer;
  681.   begin
  682.      with vBorder do
  683.      begin
  684.         getmem(SmartWinImagePtr,W*D*2);
  685.         Screen.PartSave(X1,Y1,X2,Y2,SmartWinImagePtr^);
  686.      end;
  687.   end; {CaptureSmartWin}
  688.  
  689.   procedure RestoreSmartWin;
  690.   {}
  691.   begin
  692.      with vBorder do
  693.         Screen.PartRestore(X1,Y1,X2,Y2,SmartWinImagePtr^);
  694.   end; {RestoreSmartWin}
  695.  
  696.   procedure DisposeSmartWin;
  697.   {}
  698.   begin
  699.      freemem(SmartWinImagePtr,W*D*2);
  700.   end; {DisposeSmartWin}
  701.  
  702.   procedure FastRestore(X1,Y1,X2,Y2:byte);
  703.   {}
  704.   var
  705.      I,w : byte;
  706.      ScreenAdr: integer;
  707.    begin
  708.       if (X1 > X2) or (Y1 > Y2) then
  709.          exit;
  710.       w := succ(X2 - X1);
  711.       for I :=  Y1 to Y2 do
  712.       begin
  713.          ScreenAdr := Pred(I)*Wid + Pred(X1)*2;
  714.          Screen.MoveToScreen(Mem[seg(OldPtr^):ofs(OldPtr^)+ScreenAdr],
  715.                              Mem[seg(ScrPtr^):ofs(ScrPtr^)+ScreenAdr],
  716.                               w);
  717.       end;
  718.    end; {FastRestore}
  719.  
  720. begin
  721.    with vBorder do
  722.    begin
  723.       W := succ(X2 - X1);
  724.       D := succ(Y2 - Y1);
  725.    end;
  726.    if MaxAvail < W*D*2 + Screen.Width*Screen.Depth*2 then {1.10b}
  727.    begin
  728.       Beep;
  729.       Exit;
  730.    end;
  731.    with Screen do
  732.    begin
  733.       CursSave;
  734.       CX := Screen.WhereX;
  735.       CY := Screen.WhereY;
  736.       CTop := CursTop;
  737.       CBot := CursBot;
  738.       CursOff;
  739.    end;
  740.    OriginalScreen.Init;
  741.    MVisible := Mouse.Visible;
  742.    if MVisible then
  743.       Mouse.Hide;
  744.    BuildBackground(OriginalScreen);
  745.    ScrPtr :=  Monitor^.BaseOfScreen;         {1.00a}
  746.    OldPtr := OriginalScreen.ScreenPtr;
  747.    Wid := Monitor^.Width*2;
  748.    CaptureSmartWin;
  749.    RemoveShadow(OriginalScreen);
  750.    repeat
  751.       if UsingMouse then
  752.       begin
  753.          Mouse.Show;
  754.          Mouse.Status(Left,Center,Right,X,Y);
  755.       end
  756.       else
  757.       begin
  758.          with Key do
  759.          begin
  760.             OldX := 20;
  761.             OldY := 20;
  762.             Y := 20;
  763.             X := 20;
  764.             GetInput;
  765.             Case Key.LastKey of
  766.                328: dec(Y); {up}
  767.                336: inc(Y); {down}
  768.                333: inc(X); {right}
  769.                331: dec(X); {left}
  770.             end; {case}
  771.             Left := true;
  772.          end;
  773.       end;
  774.       if Left and ( (X <> OldX) or (Y <> OldY) ) then  {move window}
  775.       begin
  776.          OldLocation := vOuter;
  777.          if (X <> OldX) then
  778.          begin
  779.             DeltaX := X - OldX;
  780.             if  (DeltaX + vBorder.X1 >= vBoundary.X1)
  781.             and (DeltaX + vBorder.X2 <= vBoundary.X2) then
  782.             begin
  783.                vBorder.X1 := vBorder.X1 + DeltaX;
  784.                vBorder.X2 := vBorder.X2 + DeltaX;
  785.             end
  786.             else DeltaX := 0;
  787.          end
  788.          else
  789.             DeltaX := 0;
  790.          if (Y <> OldY) then
  791.          begin
  792.             DeltaY := Y - OldY;
  793.             if  (DeltaY + vBorder.Y1 >= vBoundary.Y1)
  794.             and (DeltaY + vBorder.Y2 <= vBoundary.Y2) then
  795.             begin
  796.                vBorder.Y1 := vBorder.Y1 + DeltaY;
  797.                vBorder.Y2 := vBorder.Y2 + DeltaY;
  798.             end
  799.             else
  800.               DeltaY := 0;
  801.          end
  802.          else
  803.             DeltaY := 0;
  804.          ComputeSavedCoords;
  805.          Mouse.Hide;
  806.          RestoreSmartWin;
  807.          if DeltaX > 0 then {viewport moved right}
  808.             FastRestore(OldLocation.X1,vOuter.Y1,pred(vBorder.X1),vOuter.Y2)
  809.          else if DeltaX < 0 then {viewport moved left}
  810.             FastRestore(succ(vBorder.X2),vBorder.Y1,OldLocation.X2,vOuter.Y2);
  811.          if DeltaY > 0 then {Viewport moved down}
  812.             FastRestore(OldLocation.X1,OldLocation.Y1,vBorder.X2,pred(vBorder.Y1))
  813.          else if deltaY < 0 then {Viewport moved up}
  814.             FastRestore(OldLocation.X1,succ(vBorder.Y2),vBorder.X2,OldLocation.Y2);
  815.          if DeltaX < 0 then    {moved left}
  816.          begin
  817.              if (DeltaY > 0) then
  818.                 FastRestore(succ(vBorder.X1),OldLocation.Y1,Oldlocation.X2,pred(vBorder.Y1))
  819.              else
  820.                 FastRestore(succ(vBorder.X2),succ(vOuter.Y2),Oldlocation.X2,OldLocation.Y2);
  821.          end;
  822.          OldX := X;
  823.          OldY := Y;
  824.          {Mouse.Move(X,Y);}
  825.       end; {if}
  826.    until (UsingMouse and (Left = false)) or (((Key.LastKey =13) or (Key.LastKey =27)) and (UsingMouse = false));
  827.    Mouse.Hide;
  828.    WasOn := Screen.WindowOff;
  829.    ShadowTOT^.DrawShadow(vBorder);
  830.    Screen.WindowOn;
  831.    if MVisible then
  832.       Mouse.Show;
  833.    {now save new background behind window}
  834.    RefreshUnderneath(OriginalScreen);
  835.    SetWindow;
  836.    Screen.GotoXY(CX,CY);
  837.    Screen.CursSize(CTop,CBot);
  838.    OriginalScreen.Done;
  839.    DisposeSmartWin;
  840. end; {MoveWinOBJ.Move}
  841.  
  842. procedure MoveWinOBJ.SetAllowMove(On:boolean);
  843. {}
  844. begin
  845.    vAllowMove := On;
  846. end; {MoveWinOBJ.SetAllowMove}
  847.  
  848. procedure MoveWinOBJ.WinKey(var K:word;var X,Y:byte);
  849. {}
  850. begin
  851.    if (K = vMoveKey) and (vAllowMove) then
  852.       WMove(false,X,Y)
  853.    else if  (K = 513) and (Y = vBorder.Y1) and
  854.    (X >= vBorder.X1) and (X <= vBorder.X2) then
  855.    begin
  856.       if (X = vBorder.X1 + 3) and vClose then
  857.       begin
  858.          if vRemove then  {1.10d}
  859.             Remove;
  860.          K := 600;  {Closed}
  861.          Key.vLastKey := K;  {1.00e}
  862.          Mouse.WaitForRelease;  {1.10c}
  863.       end
  864.       else if vAllowMove then
  865.       begin
  866.          WMove(true,X,Y);
  867.          K := 601;  {Moved}
  868.       end;
  869.    end;
  870. end; {MoveWinOBJ.WinKey}
  871.  
  872. destructor MoveWinOBJ.Done;
  873. {}
  874. begin
  875.    WinOBJ.Done;
  876. end; {MoveWinOBJ.Done}
  877. {||||||||||||||||||||||||||||||||||||||||||||||||}
  878. {                                                }
  879. {    S c r o l l W i n O B J   M E T H O D S     }
  880. {                                                }
  881. {||||||||||||||||||||||||||||||||||||||||||||||||}
  882. constructor ScrollWinOBJ.Init;
  883. {}
  884. begin
  885.    MoveWinOBJ.Init;
  886.    vScrollV := false;
  887.    vScrollH := false;
  888. end; {ScrollWinOBJ.Init}
  889.  
  890. procedure ScrollWinOBJ.SetScrollable(Vert,Horiz:boolean);
  891. {}
  892. begin
  893.    vScrollV := Vert;
  894.    vScrollH := Horiz;
  895. end; {ScrollWinOBJ.SetScrollable}
  896.  
  897. procedure ScrollWinOBJ.DrawHorizBar(Current,Max: longint);
  898. {}
  899. var
  900.   WasOn: boolean;
  901.   CursX,CursY : byte;
  902. begin
  903.    if (vStyle in [1..5]) and (vScrollH) then
  904.    begin
  905.       CursX := Screen.WhereX;
  906.       CursY := Screen.WhereY;
  907.       WasOn := Screen.WindowOff;
  908.       with vBorder do
  909.          Screen.WriteHScrollBar(succ(X1),pred(X2),Y2,vBorderAttr,Current,Max);
  910.       SetWindow;
  911.       Screen.GotoXY(CursX,CursY);
  912.    end; 
  913. end; {ScrollWinOBJ.DrawHorizBar}
  914.  
  915. procedure ScrollWinOBJ.DrawVertBar(Current,Max: longint);
  916. {}
  917. var
  918.    WasOn: boolean;
  919.    CursX,CursY : byte;
  920. begin
  921.    if (vStyle in [1..5]) and (vScrollV) then
  922.    begin
  923.       CursX := Screen.WhereX;
  924.       CursY := Screen.WhereY;
  925.       WasOn := Screen.WindowOff;
  926.       with vBorder do
  927.          Screen.WriteVScrollBar(X2,succ(Y1),pred(Y2),vBorderAttr,Current,Max);
  928.       SetWindow;
  929.       Screen.GotoXY(CursX,CursY);
  930.    end;
  931. end; {ScrollWinOBJ.DrawVertBar}
  932.  
  933. procedure ScrollWinOBJ.WinKey(var K:word;var X,Y:byte);
  934. { RetCodes
  935. 610 = Scroll Up One
  936. 611 = Scroll Down One
  937. 612 = Scroll Left one
  938. 613 = Scroll Right one
  939. 614 = Vertical Scroll Bar
  940. 615 = Horizontal Scroll Bar
  941. }
  942. begin
  943.    if (K = vMoveKey) and (vAllowMove) then {1.00d}
  944.       WMove(false,X,Y)
  945.    else if  (K = 513) then
  946.    begin
  947.       if (Y = vBorder.Y1) and
  948.       (X >= vBorder.X1) and (X <= vBorder.X2) then
  949.       begin
  950.          if (X = vBorder.X1 + 3) and vClose then
  951.          begin
  952.             if vRemove then  {1.10d}
  953.                Remove;
  954.             K := 600;  {Closed}
  955.             Key.vLastKey := K;  {1.00e}
  956.          end
  957.          else if vAllowMove then {1.00d}
  958.          begin
  959.             WMove(true,X,Y);
  960.             K := 601;  {Moved}
  961.          end;
  962.       end
  963.       else if vScrollV and (X = vBorder.X2) then
  964.       begin
  965.           if  Y = succ(vBorder.Y1) then
  966.              K := 610
  967.           else if Y =  pred(vBorder.Y2)  then
  968.              K := 611
  969.           else if  (Y > succ(vBorder.Y1))
  970.              and (Y < pred(vBorder.Y2)) then {scroll bar}
  971.              begin
  972.                 {adjust X to represent no of characters down scroll bar}
  973.                 {adjust Y to return total length of scroll bar}
  974.                 K := 614;
  975.                 X := Y - succ(vBorder.Y1);
  976.                 Y := vBorder.Y2 - vBorder.Y1 - 3;
  977.              end;
  978.       end
  979.       else  if vScrollH and (Y = vBorder.Y2) then
  980.       begin
  981.          if X = succ(vBorder.X1) then
  982.             K := 612
  983.          else if X = pred(vBorder.X2) then
  984.             K := 613
  985.          else if  (X > succ(vBorder.X1))
  986.             and (X < pred(vBorder.X2)) then
  987.             begin
  988.                K := 615;
  989.                X := X - succ(vBorder.X1);
  990.                Y := vBorder.X2 - vBorder.X1 - 3;
  991.             end;
  992.       end;
  993.    end;
  994. end; {ScrollWinOBJ.WinKey}
  995.  
  996. procedure ScrollWinOBJ.Draw;
  997. {}
  998. begin
  999.    if not (vStyle in [1..5]) then
  1000.       vStyle := 1;
  1001.    MoveWinOBJ.Draw;
  1002. end; {ScrollWinOBJ.Draw}
  1003.  
  1004. destructor ScrollWinOBJ.Done;
  1005. {}
  1006. begin
  1007.    MoveWinOBJ.Done;
  1008. end; {ScrollWinOBJ.Done}
  1009. {||||||||||||||||||||||||||||||||||||||||||||||||||}
  1010. {                                                  }
  1011. {    S t r e t c h W i n O B J   M E T H O D S     }
  1012. {                                                  }
  1013. {||||||||||||||||||||||||||||||||||||||||||||||||||}
  1014. constructor StretchWinOBJ.Init;
  1015. {}
  1016. begin
  1017.    ScrollWinOBJ.Init;
  1018.    vZoomed := false;
  1019.    vPreZoom := vBorder;
  1020.    vMinWidth := 10;
  1021.    vMinDepth := 5;
  1022.    vStretchKey:= LookTOT^.vWinStretchKey;
  1023.    vZoomKey:= LookTOT^.vWinZoomKey;
  1024.    vAllowStretch := true;
  1025.    vSmartStretch := false;
  1026. end; {StretchWinOBJ.Init}
  1027.  
  1028. procedure StretchWinOBJ.SetAllowStretch(On:boolean);
  1029. {}
  1030. begin
  1031.    vAllowStretch := On;
  1032. end; {StretchWinOBJ.SetAllowStretch}
  1033.  
  1034. procedure StretchWinOBJ.SetMinSize(Width,depth:byte);
  1035. {}
  1036. begin
  1037.    vMinWidth := width;
  1038.    vMinDepth := depth;
  1039. end; {StretchWinOBJ.SetMinSize}
  1040.  
  1041. procedure StretchWinOBJ.ToggleZoom;
  1042. {zooms or unzooms a window}
  1043. begin
  1044.    vZoomed := not vZoomed;
  1045.    Remove;             {remove the window}
  1046.    if vUnderneathPtr <> Nil then
  1047.       FreeMem(vUnderneathPtr,succ(vOuter.X2-vOuter.X1)*succ(vOuter.Y2-vOuter.Y1)*2);
  1048.    if not vZoomed then
  1049.       vBorder := vPreZoom  {set zone coords back to the old coords}
  1050.    else
  1051.    begin
  1052.       vPreZoom := vBorder;  {save the un-zoomed coordinates}
  1053.       vBorder := vBoundary; {set window coords to the maximum}
  1054.    end;      
  1055.    ComputeSavedCoords;
  1056.    Draw;        
  1057. end; {StretchWinOBJ.ToggleZoom}
  1058.  
  1059. procedure StretchWinOBJ.StretchRefresh;
  1060. {abstract} begin end;
  1061.  
  1062. procedure StretchWinOBJ.Stretch(UsingMouse:boolean;OldX,OldY:byte);
  1063. {}
  1064. const
  1065.    BorderChar = '█';
  1066.    Col = white;
  1067. var
  1068.    Mvisible,
  1069.    WasOn: boolean;
  1070.    Left,Center,Right : boolean;
  1071.    CTop,CBot,CX,CY:byte;
  1072.    NewX,NewY,
  1073.    X,Y : Byte;
  1074.    OriginalScreen: ScreenOBJ;
  1075.    BackScreen: ScreenOBJ;
  1076.    OldWin: tByteCoords;                   {1.00c}
  1077.    OldWinConfine: boolean;
  1078.  
  1079.      procedure ChangePerimeter;
  1080.      {}
  1081.      var
  1082.        I : integer;
  1083.      begin
  1084.         if NewX <> vBorder.X2 then
  1085.         with vBorder do
  1086.         begin
  1087.            OriginalScreen.PartDisplay(X2,Y1,X2,Y2,X2,Y1);
  1088.            if NewX < X2 then
  1089.            begin
  1090.               OriginalScreen.PartDisplay(succ(NewX),Y1,X2,Y2,succ(NewX),Y1);
  1091.               OriginalScreen.PartDisplay(succ(NewX),Y2,X2,Y2,succ(NewX),Y2);
  1092.            end;
  1093.         end;
  1094.         if NewY <> vBorder.Y2 then
  1095.         with vBorder do
  1096.         begin
  1097.            OriginalScreen.PartDisplay(X1,Y2,X2,Y2,X1,Y2);
  1098.            if NewY < Y2 then
  1099.            begin
  1100.               OriginalScreen.PartDisplay(X1,succ(NewY),X2,Y2,X1,succ(NewY));
  1101.               OriginalScreen.PartDisplay(X2,succ(NewY),X2,Y2,X2,succ(NewY));
  1102.            end;
  1103.         end;
  1104.         {draw new perimiter}
  1105.         with vBorder do
  1106.         begin
  1107.            X2 := NewX;
  1108.            Y2 := NewY;
  1109.            Screen.Box(X1,Y1,X2,Y2,white,ord(BorderChar));
  1110.         end;
  1111.      end;
  1112. begin
  1113.    if MaxAvail < 4*Screen.Width*Screen.Depth then
  1114.    begin
  1115.       Beep;
  1116.       exit;
  1117.    end;
  1118.    WasOn := Screen.WindowOff;
  1119.    OriginalScreen.Init;
  1120.    MVisible := Mouse.Visible;
  1121.    if MVisible then
  1122.       Mouse.Hide;
  1123.    OriginalScreen.Save;
  1124.    BackScreen.Init;
  1125.    BuildBackground(BackScreen);
  1126.    if vSmartStretch then
  1127.       with OriginalScreen do
  1128.          move(Backscreen.ScreenPtr^,ScreenPtr^,Depth*Width*2);
  1129.    if vUnderneathPtr <> Nil then
  1130.    begin
  1131.        FreeMem(vUnderneathPtr,vSavedSize);
  1132.        vUnderneathPtr := Nil;
  1133.    end;
  1134.    OldWin := vOldWin;                    {1.00c}
  1135.    OldWinConfine := vOldWinConfine;
  1136.    with vBorder do
  1137.    begin
  1138.       Screen.Box(X1,Y1,X2,Y2,col,ord(BorderChar));
  1139.       OldX := X2;
  1140.       OldY := Y2;
  1141.    end;
  1142.    RemoveShadow(OriginalScreen);
  1143.    with Screen do
  1144.    begin
  1145.       CursSave;
  1146.       CX := Screen.WhereX;
  1147.       CY := Screen.WhereY;
  1148.       CTop := CursTop;
  1149.       CBot := CursBot;
  1150.       CursOff;
  1151.    end;
  1152.    Repeat
  1153.       if UsingMouse then
  1154.       begin
  1155.          Mouse.Show;
  1156.          Mouse.Status(Left,Center,Right,X,Y);
  1157.       end
  1158.       else
  1159.       begin
  1160.          with Key do
  1161.          begin
  1162.             OldX := vBorder.X2;
  1163.             OldY := vBorder.Y2;
  1164.             Y := OldY;
  1165.             X := OldX;
  1166.             GetInput;
  1167.             Case Key.LastKey of
  1168.                328: dec(Y); {up}
  1169.                336: inc(Y); {down}
  1170.                333: inc(X); {right}
  1171.                331: dec(X); {left}
  1172.             end; {case}
  1173.          end;
  1174.          Left := true;
  1175.       end;
  1176.       if Left and ( (X <> OldX) or (Y <> OldY) ) then  {stretch window}
  1177.       begin
  1178.          if (succ(X - vBorder.X1 ) < vMinWidth) then  {too small}
  1179.             NewX := pred(vBorder.X1 + vMinWidth)
  1180.          else
  1181.          if (X > vBoundary.X2) then                 {out of bounds}
  1182.             NewX := vBoundary.X2
  1183.          else
  1184.             NewX := X;
  1185.          if (succ(Y - vBorder.Y1 ) < vMinDepth) then  {too small}
  1186.             NewY := pred(vBorder.Y1 + vMinDepth)
  1187.          else
  1188.          if (Y > vBoundary.Y2) then                 {out of bounds}
  1189.             NewY := vBoundary.Y2
  1190.          else
  1191.             NewY := Y;
  1192.          ChangePerimeter;
  1193.          if vSmartStretch then
  1194.             StretchRefresh;
  1195.          OldX := NewX;
  1196.          OldY := NewY;
  1197.       end; {if}
  1198.    until (UsingMouse and (Left = false)) or (((Key.LastKey =13) or (Key.LastKey = 27)) and (UsingMouse = false));
  1199.    ComputeSavedCoords;
  1200.    { draw the new image }
  1201.    BackScreen.Display;
  1202.    OriginalScreen.Done;
  1203.    BackScreen.Done;
  1204.    vZoomed := (vBorder.X1 = vBoundary.X1)
  1205.                and (vBorder.Y1 = vBoundary.Y1)
  1206.                and (vBorder.X2 = vBoundary.X2)
  1207.                and (vBorder.Y2 = vBoundary.Y2);
  1208.    SetWindow;
  1209.    Draw;
  1210.    vOldWin := OldWin;                      {1.00c}
  1211.    vOldWinConfine := OldWinConfine;
  1212.    Screen.GotoXY(CX,CY);
  1213.    Screen.CursSize(CTop,CBot);
  1214.    if MVisible then
  1215.       Mouse.Show;
  1216. end; {StretchWinOBJ.Stretch}
  1217.  
  1218. procedure StretchWinOBJ.Winkey(var K:word;var X,Y:byte);
  1219. {}
  1220. begin
  1221.    if (K = vStretchKey) and vAllowStretch then
  1222.    begin
  1223.       Stretch(false,X,Y);
  1224.       K := 602;
  1225.    end
  1226.    else if (K = 513) and (X = vBorder.X2) and (Y = vBorder.Y2) and vAllowStretch then
  1227.    begin
  1228.       Stretch(true,X,Y);
  1229.       K := 602;
  1230.    end
  1231.    else if (((K = 513) and (X = vBorder.X2 - 3) and (Y = vBorder.Y1))
  1232.         or (K = vZoomKey)) and vAllowStretch then
  1233.    begin
  1234.       ToggleZoom;
  1235.       K := 602;
  1236.    end
  1237.    else
  1238.       ScrollWinOBJ.WinKey(K,X,Y);
  1239. end; {StretchWinOBJ.Winkey}
  1240.  
  1241. procedure StretchWinOBJ.Refresh;
  1242. {}
  1243. var WasOn: boolean;
  1244. begin
  1245.    WasOn := Screen.WindowOff;
  1246.    ShadowTOT^.DrawShadow(vBorder);
  1247.    if vClose then
  1248.    begin
  1249.       with vBorder do
  1250.       begin
  1251.          Screen.BoxEngine(X1,Y1,X2,Y2,4,4,vBorderAttr,vTitleAttr,vBodyAttr,vStyle,true,vTitle);
  1252.          Screen.WriteAT(X1+2,Y1,vBorderAttr,'[ ]');
  1253.          Screen.WriteAT(X1+3,Y1,vIconsAttr,'■');
  1254.       end;
  1255.    end
  1256.    else
  1257.       with vBorder do
  1258.          Screen.BoxEngine(X1,Y1,X2,Y2,0,4,vBorderAttr,vTitleAttr,vBodyAttr,vStyle,true,vTitle);
  1259.    if vAllowStretch then
  1260.    begin
  1261.       Screen.WriteAT(vBorder.X2-4,vBorder.Y1,vBorderAttr,'[ ]');
  1262.       if not vZoomed then
  1263.          Screen.WriteAT(vBorder.X2-3,vBorder.Y1,vIconsAttr,'')
  1264.       else
  1265.          Screen.WriteAT(vBorder.X2-3,vBorder.Y1,vIconsAttr,'');
  1266.    end;
  1267.    SetWindow;
  1268. end; {StretchWinOBJ.Refresh}
  1269.  
  1270. procedure StretchWinOBJ.Draw;
  1271. {}
  1272. begin
  1273.    if not (vStyle in [1..5]) then
  1274.       vStyle := 1;
  1275.    Save;
  1276.    vMVisible := Mouse.Visible;
  1277.    Refresh;
  1278.    if not vMVisible then
  1279.       Mouse.Show;
  1280. end; {StretchWinOBJ.Draw}
  1281.  
  1282. destructor StretchWinOBJ.Done;
  1283. {}
  1284. begin
  1285.    ScrollWinOBJ.Done;
  1286. end; {StretchWinOBJ.Done}
  1287. {|||||||||||||||||||||||||||||||||||||||||||||||}
  1288. {                                               }
  1289. {     U N I T   I N I T I A L I Z A T I O N     }
  1290. {                                               }
  1291. {|||||||||||||||||||||||||||||||||||||||||||||||}
  1292. procedure WinInit;
  1293. {initilizes objects and global variables}
  1294. begin
  1295. end;
  1296.  
  1297. {end of unit - add intialization routines below}
  1298. {$IFNDEF OVERLAY}
  1299. begin
  1300.    WinInit;
  1301. {$ENDIF}
  1302. end.
  1303.